import 'package:flutter/material.dart';

class News16 extends StatefulWidget {
  const News16({super.key});

  @override
  State<News16> createState() => _News16State();
}

class _News16State extends State<News16> with AutomaticKeepAliveClientMixin {
  @override
  void initState() {
    super.initState();
    print('========新闻创建');
  }

  @override
  void dispose() {
    super.dispose();
    print('=========新闻销毁');
  }

  @override
  Widget build(BuildContext context) {
    super.build(context); // 调用 super.build(context) 来启用 keepAlive 功能
    return const Placeholder(child: Text('新闻'));
  }

  @override
  bool get wantKeepAlive => true; // 保证返回 true 表示需要保持页面状态
}
